from typing import Annotated

from fastapi import Body, FastAPI

import api.service.user_service as user_service
from api.vo.ResponseVo import ResponsePageVo, ResponseVo
from api.vo.form.user_form import UserVo
from api.vo.query.user_query import User_Query

async def exists(userQo: User_Query):
    return user_service.exists(userQo.name)

async def login(userVo: UserVo):
    return user_service.login(username=userVo.username, pwd=userVo.pwd)

async def list_user(userQo: User_Query):
    print(userQo)
    return await user_service.list(userQo)


async def create_user(userVo: UserVo):
    return user_service.create(userVo)

async def get_user_info():
    return {
        "user": "zhangsan",
        "age": 23
    }


async def update_user_info():
    pass

def add_user_routes(app: FastAPI):
    app.get("/user/info", summary="获取用户信息", description="获取用户信息")(get_user_info)
    app.post("/user/register", summary="注册用户", description="注册用户")(create_user)
    app.post("/user/login", summary="登录用户", description="登录用户")(login)
    app.post("/user/update", summary="更新用户信息", description="更新用户信息")(update_user_info)
    app.post("/user/list", summary="获取用户列表", description="获取用户列表")(list_user)
    app.post("/user/exists", summary="用户是否存在", description="用户是否存在")(exists)